home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / standard / sync.z / sync
Encoding:
Text File  |  1998-10-30  |  13.9 KB  |  331 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. SSSSYYYYNNNNCCCC((((3333CCCC))))                                                              SSSSYYYYNNNNCCCC((((3333CCCC))))
  71.  
  72.  
  73.  
  74. NNNNAAAAMMMMEEEE
  75.      sync: __synchronize, __fetch_and_add, __fetch_and_sub, __fetch_and_or,
  76.      __fetch_and_and, __fetch_and_xor, __fetch_and_nand, __add_and_fetch,
  77.      __sub_and_fetch, __or_and_fetch, __and_and_fetch, __xor_and_fetch,
  78.      __nand_and_fetch, __lock_test_and_set, __lock_release- C synchronization
  79.      primitives for multiprocessing
  80.  
  81. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  82.      See summaries below
  83.  
  84.  
  85. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  86.      The intrinsics described here provide a variety of primitive
  87.      synchronization operations. Besides performing the particular
  88.      synchronization operation, each of these intrinsics has two key
  89.      properties:
  90.  
  91.          The function performed is guaranteed to be atomic (typically achieved
  92.          by implementing the operation using a sequence of load-linked/store-
  93.          conditional instructions in a loop).
  94.  
  95.          Associated with each instrinsic are certain _m_e_m_o_r_y _b_a_r_r_i_e_r properties
  96.          that restrict the movement of memory references to _v_i_s_i_b_l_e _d_a_t_a
  97.          across the intrinsic operation (by either the compiler or the
  98.          processor).
  99.  
  100.          A visible memory reference is a reference to a data object
  101.          potentially accessible by another thread executing in the same shared
  102.          address space. A visible data object may be one of the following:
  103.  
  104.              C/C++ global data
  105.  
  106.              Fortran COMMON data
  107.  
  108.              data declared _e_x_t_e_r_n
  109.  
  110.              volatile data
  111.  
  112.              static data (either file-scope or function-scope)
  113.  
  114.              data accessible via function parameters
  115.  
  116.              automatic data (local-scope) that has had its address taken and
  117.              assigned to some object which is visible (recursively).
  118.  
  119.  
  120.          The memory barrier semantics of an intrinsic may be one of the
  121.          following three types:
  122.  
  123.              aaaaccccqqqquuuuiiiirrrreeee bbbbaaaarrrrrrrriiiieeeerrrr
  124.  
  125.              Disallows the movement of memory references to visible data from
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. SSSSYYYYNNNNCCCC((((3333CCCC))))                                                              SSSSYYYYNNNNCCCC((((3333CCCC))))
  137.  
  138.  
  139.  
  140.              after the intrinsic (in program order) to before the intrinsic
  141.              (this behavior is desirable at lock-acquire operations, hence the
  142.              name).
  143.  
  144.  
  145.              rrrreeeelllleeeeaaaasssseeee bbbbaaaarrrrrrrriiiieeeerrrr
  146.  
  147.              Disallows the movement of memory references to visible data from
  148.              before the intrinsic (in program order) to after the intrinsic
  149.              (this behavior is desirable at lock-release operations, hence the
  150.              name).
  151.  
  152.              ffffuuuullllllll bbbbaaaarrrrrrrriiiieeeerrrr
  153.  
  154.              disallows the movement of memory references to visible data past
  155.              the intrinsic (in either direction), and is thus both an acquire
  156.              and a release barrier. A barrier only restricts the movement of
  157.              memory references to visible data across the intrinsic operation:
  158.              between synchronization operations (or in their absence), memory
  159.              references to visible data may be freely reordered subject to the
  160.              usual data-dependence constraints.
  161.  
  162.      CCCCaaaauuuuttttiiiioooonnnn:::: Conditional execution of a synchronization intrinsic (such as
  163.      within a _i_f or a _w_h_i_l_e statement) does not prevent the movement of memory
  164.      references to visible data past the overall _i_f or _w_h_i_l_e construct.
  165.  
  166.  
  167.      AAAAttttoooommmmiiiicccc ffffeeeettttcccchhhh----aaaannnndddd----oooopppp OOOOppppeeeerrrraaaattttiiiioooonnnnssss
  168.  
  169.      ttttyyyyppppeeee ________ffffeeeettttcccchhhh____aaaannnndddd____aaaadddddddd ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  170.  
  171.      ttttyyyyppppeeee ________ffffeeeettttcccchhhh____aaaannnndddd____ssssuuuubbbb ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  172.  
  173.      ttttyyyyppppeeee ________ffffeeeettttcccchhhh____aaaannnndddd____oooorrrr  ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  174.  
  175.      ttttyyyyppppeeee ________ffffeeeettttcccchhhh____aaaannnndddd____aaaannnndddd ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  176.  
  177.      ttttyyyyppppeeee ________ffffeeeettttcccchhhh____aaaannnndddd____xxxxoooorrrr ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  178.  
  179.      ttttyyyyppppeeee ________ffffeeeettttcccchhhh____aaaannnndddd____nnnnaaaannnndddd((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  180.  
  181.          Where ttttyyyyppppeeee may be one of _i_n_t, _l_o_n_g, _l_o_n_g _l_o_n_g, _u_n_s_i_g_n_e_d _i_n_t, _u_n_s_i_g_n_e_d
  182.          _l_o_n_g, or _u_n_s_i_g_n_e_d _l_o_n_g _l_o_n_g.
  183.          The ellipses (...) refers to an optional list of variables protected
  184.          by the memory barrier.
  185.  
  186.          Behavior:
  187.  
  188.              Atomically performs the specified operation with the given value
  189.              on *ptr, and returns the old value of *ptr. (i.e.)
  190.  
  191.                  { tmp = *ptr; *ptr <op>= value; return tmp; }
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. SSSSYYYYNNNNCCCC((((3333CCCC))))                                                              SSSSYYYYNNNNCCCC((((3333CCCC))))
  203.  
  204.  
  205.  
  206.              Full barrier.
  207.  
  208.  
  209.  
  210.      AAAAttttoooommmmiiiicccc oooopppp----aaaannnndddd----ffffeeeettttcccchhhh OOOOppppeeeerrrraaaattttiiiioooonnnnssss
  211.  
  212.      ttttyyyyppppeeee ________aaaadddddddd____aaaannnndddd____ffffeeeettttcccchhhh ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  213.  
  214.      ttttyyyyppppeeee ________ssssuuuubbbb____aaaannnndddd____ffffeeeettttcccchhhh ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  215.  
  216.      ttttyyyyppppeeee ________oooorrrr____aaaannnndddd____ffffeeeettttcccchhhh  ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  217.  
  218.      ttttyyyyppppeeee ________aaaannnndddd____aaaannnndddd____ffffeeeettttcccchhhh ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  219.  
  220.      ttttyyyyppppeeee ________xxxxoooorrrr____aaaannnndddd____ffffeeeettttcccchhhh ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  221.  
  222.      ttttyyyyppppeeee ________nnnnaaaannnndddd____aaaannnndddd____ffffeeeettttcccchhhh((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  223.  
  224.          Where ttttyyyyppppeeee may be one of _i_n_t, _l_o_n_g, _l_o_n_g _l_o_n_g, _u_n_s_i_g_n_e_d _i_n_t, _u_n_s_i_g_n_e_d
  225.          _l_o_n_g, or _u_n_s_i_g_n_e_d _l_o_n_g _l_o_n_g. The ellipses (...) refers to an optional
  226.          list of variables protected by the memory barrier.
  227.  
  228.          Behavior:
  229.  
  230.              Atomically performs the specified operation with the given value
  231.              on *ptr, and returns the new value of *ptr. (i.e.)
  232.  
  233.                  { *ptr <op>= value; return *ptr; }
  234.  
  235.              Full barrier.
  236.  
  237.  
  238.      AAAAttttoooommmmiiiicccc ccccoooommmmppppaaaarrrreeee----aaaannnndddd----sssswwwwaaaapppp OOOOppppeeeerrrraaaattttiiiioooonnnn
  239.  
  240.      iiiinnnntttt ________ccccoooommmmppppaaaarrrreeee____aaaannnndddd____sssswwwwaaaapppp ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee oooollllddddvvvvaaaalllluuuueeee,,,, ttttyyyyppppeeee nnnneeeewwwwvvvvaaaalllluuuueeee,,,, ............))))
  241.  
  242.          Where ttttyyyyppppeeee may be one of _i_n_t, _l_o_n_g, _l_o_n_g _l_o_n_g, _u_n_s_i_g_n_e_d _i_n_t, _u_n_s_i_g_n_e_d
  243.          _l_o_n_g, or _u_n_s_i_g_n_e_d _l_o_n_g _l_o_n_g. The ellipses (...) refers to an optional
  244.          list of variables protected by the memory barrier.
  245.  
  246.          Behavior:
  247.  
  248.              Atomically do the following: compare *ptr to oldvalue. If equal,
  249.              store the new value and return 1, otherwise return 0. (i.e.)
  250.  
  251.                  if (*ptr != oldvalue) return 0;
  252.  
  253.                  else {
  254.  
  255.                          *ptr = newvalue;
  256.  
  257.                          return 1; }
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. SSSSYYYYNNNNCCCC((((3333CCCC))))                                                              SSSSYYYYNNNNCCCC((((3333CCCC))))
  269.  
  270.  
  271.  
  272.              Full barrier.
  273.  
  274.  
  275.  
  276.      AAAAttttoooommmmiiiicccc ssssyyyynnnncccchhhhrrrroooonnnniiiizzzzeeee OOOOppppeeeerrrraaaattttiiiioooonnnn
  277.  
  278.      ________ssssyyyynnnncccchhhhrrrroooonnnniiiizzzzeeee ((((............))))
  279.  
  280.      The ellipses (...) refers to an optional list of variables protected by
  281.      the memory barrier.
  282.  
  283.          Behavior:
  284.              Full barrier
  285.  
  286.  
  287.  
  288.      AAAAttttoooommmmiiiicccc lllloooocccckkkk----tttteeeesssstttt----aaaannnndddd----sssseeeetttt OOOOppppeeeerrrraaaattttiiiioooonnnn
  289.  
  290.      ttttyyyyppppeeee ________lllloooocccckkkk____tttteeeesssstttt____aaaannnndddd____sssseeeetttt ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ttttyyyyppppeeee vvvvaaaalllluuuueeee,,,, ............))))
  291.  
  292.          Where ttttyyyyppppeeee may be one of _i_n_t, _l_o_n_g, _l_o_n_g _l_o_n_g, _u_n_s_i_g_n_e_d _i_n_t, _u_n_s_i_g_n_e_d
  293.          _l_o_n_g, or _u_n_s_i_g_n_e_d _l_o_n_g _l_o_n_g. The ellipses (...) refers to an optional
  294.          list of variables protected by the memory barrier.
  295.  
  296.          Behavior
  297.  
  298.              Atomically store the supplied value in *ptr and return the old
  299.              value of *ptr. (i.e.)
  300.  
  301.                  { tmp = *ptr; *ptr = value; return tmp; }
  302.  
  303.              Acquire barrier
  304.  
  305.  
  306.      AAAAttttoooommmmiiiicccc lllloooocccckkkk____rrrreeeelllleeeeaaaasssseeee OOOOppppeeeerrrraaaattttiiiioooonnnn
  307.  
  308.      vvvvooooiiiidddd ________lllloooocccckkkk____rrrreeeelllleeeeaaaasssseeee ((((ttttyyyyppppeeee**** ppppttttrrrr,,,, ............))))
  309.  
  310.          Where ttttyyyyppppeeee may be one of _i_n_t, _l_o_n_g, _l_o_n_g _l_o_n_g, _u_n_s_i_g_n_e_d _i_n_t, _u_n_s_i_g_n_e_d
  311.          _l_o_n_g, or _u_n_s_i_g_n_e_d _l_o_n_g _l_o_n_g. The ellipses (...) refers to an optional
  312.          list of variables protected by the memory barrier.
  313.  
  314.          Behavior:
  315.  
  316.              Set *ptr to 0.  (i.e.) { *ptr = 0 }
  317.  
  318.              Release barrier
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.